
import 'package:flutter_elf/utils/get_utils.dart';
import 'package:flutter_hls_parser/flutter_hls_parser.dart';

String url = 'https://eqmumbaby.com/20191224/DsmWujAa/index.m3u8';
String url2 = 'https://eqmumbaby.com/20191224/DsmWujAa/1000kb/hls/index.m3u8';
void main()async{
  String m3u8Content = await HttpUtils.get(url2);
  Uri playlistUri;
  var playList;
  List<String> lines;
  try {
    playList = await HlsPlaylistParser.create().parseString(playlistUri, m3u8Content);
  } on ParserException catch (e) {
    print(e);
  }

  print(playList);
  if (playList is HlsMasterPlaylist) {//master需要重新请求一次
    print("Master======>"+playList.mediaPlaylistUrls[0].toString());
    // master m3u8 file
  } else if (playList is HlsMediaPlaylist) {
    print("Media======>"+playList.toString());
    print(playList.segments[0].url);
    // media m3u8 file
  }
  await Future.delayed(Duration(seconds: 12));

}

